cpuidle: export max_cstate access via libxc
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 31 Mar 2009 10:19:26 +0000 (11:19 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 31 Mar 2009 10:19:26 +0000 (11:19 +0100)
Signed-off-by: Wei Gang <gang.wei@intel.com>
tools/libxc/xc_pm.c
tools/libxc/xenctrl.h
xen/drivers/acpi/pmstat.c
xen/include/public/sysctl.h

index 13342a31213f32ead12f19196e4eb5e1187ffc78..652f1729efe6141cc74ea014b02b1eb3d7b7555d 100644 (file)
@@ -362,3 +362,36 @@ int xc_set_sched_opt_smt(int xc_handle, uint32_t value)
    return rc;
 }
 
+int xc_get_cpuidle_max_cstate(int xc_handle, uint32_t *value)
+{
+    int rc;
+    DECLARE_SYSCTL;
+
+    if ( xc_handle < 0 || !value )
+        return -EINVAL;
+
+    sysctl.cmd = XEN_SYSCTL_pm_op;
+    sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_get_max_cstate;
+    sysctl.u.pm_op.cpuid = 0;
+    sysctl.u.pm_op.get_max_cstate = 0;
+    rc = do_sysctl(xc_handle, &sysctl);
+    *value = sysctl.u.pm_op.get_max_cstate;
+
+    return rc;
+}
+
+int xc_set_cpuidle_max_cstate(int xc_handle, uint32_t value)
+{
+    DECLARE_SYSCTL;
+
+    if ( xc_handle < 0 )
+        return -EINVAL;
+
+    sysctl.cmd = XEN_SYSCTL_pm_op;
+    sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_set_max_cstate;
+    sysctl.u.pm_op.cpuid = 0;
+    sysctl.u.pm_op.set_max_cstate = value;
+
+    return do_sysctl(xc_handle, &sysctl);
+}
+
index 9ce228620a870f33c4c6661f6ad3a9c08f02e15e..7111fa97c576f62d351b47e5fd725e082491664e 100644 (file)
@@ -1262,4 +1262,7 @@ int xc_get_cputopo(int xc_handle, struct xc_get_cputopo *info);
 
 int xc_set_sched_opt_smt(int xc_handle, uint32_t value);
 
+int xc_get_cpuidle_max_cstate(int xc_handle, uint32_t *value);
+int xc_set_cpuidle_max_cstate(int xc_handle, uint32_t value);
+
 #endif /* XENCTRL_H */
index 1ac35c8237082dc691d96e964d43efa6282e0bc0..8125e88951e4350d65c0671e94fc520772005e96 100644 (file)
@@ -37,6 +37,7 @@
 #include <asm/processor.h>
 #include <xen/percpu.h>
 #include <xen/domain.h>
+#include <xen/acpi.h>
 
 #include <public/sysctl.h>
 #include <acpi/cpufreq/cpufreq.h>
@@ -527,6 +528,18 @@ int do_pm_op(struct xen_sysctl_pm_op *op)
         break;
     }
 
+    case XEN_SYSCTL_pm_op_get_max_cstate:
+    {
+        op->get_max_cstate = max_cstate;
+        break;
+    }
+
+    case XEN_SYSCTL_pm_op_set_max_cstate:
+    {
+        max_cstate = op->set_max_cstate;
+        break;
+    }
+
     default:
         printk("not defined sub-hypercall @ do_pm_op\n");
         ret = -ENOSYS;
index 48d327c06775eaea875bbc78e972be3cbf6c107c..cb03262bd2bc8ab8aec42e3428cb95c29957a8e3 100644 (file)
@@ -382,6 +382,10 @@ struct xen_sysctl_pm_op {
     /* set/reset scheduler power saving option */
     #define XEN_SYSCTL_pm_op_set_sched_opt_smt    0x21
 
+    /* cpuidle max_cstate access command */
+    #define XEN_SYSCTL_pm_op_get_max_cstate       0x22
+    #define XEN_SYSCTL_pm_op_set_max_cstate       0x23
+
     uint32_t cmd;
     uint32_t cpuid;
     union {
@@ -391,6 +395,8 @@ struct xen_sysctl_pm_op {
         uint64_t get_avgfreq;
         struct xen_get_cputopo      get_topo;
         uint32_t                    set_sched_opt_smt;
+        uint32_t                    get_max_cstate;
+        uint32_t                    set_max_cstate;
     };
 };